﻿@page "/admin"
@model AdminPage


<partial name="Shared/_AdminPartial"/>
<h4 class="p-2 m-2">服务器动态表</h4>
<div class="container-fluid">
    <div class="row">
        <table class="table table-sm table-striped table-bordered p-2 m-2">
            <thead>
            <tr>
                <th>服务器限制(/min)</th>
                <th>剩余请求</th>
            </tr>
            </thead>
            <tbody>
            <td>@Model.ServerBaseLimit.ServerServeLimit</td>
            <td>@Model.Table.ServerServeAvailable</td>
            </tbody>
        </table>
        <table class="table table-sm table-striped table-bordered p-2 m-2">
            <thead>
            <tr>
                <th>服务器Ip限制(/min)</th>
                <th>Ip地址</th>
                <th>IP剩余请求</th>
            </tr>
            </thead>

            <tbody>
            @if (Model.Table.IpAvailable.Count == 0)
            {
                <tr>
                    <td>@Model.ServerBaseLimit.IpRequestLimit</td>
                    <td></td>
                    <td></td>
                </tr>
            }
            else
            {
                @foreach (var ipPair in Model.Table.IpAvailable)
                {
                    <tr>
                        <td>@Model.ServerBaseLimit.IpRequestLimit</td>
                        <td>@ipPair.Key</td>
                        <td>@ipPair.Value</td>
                    </tr>
                }
            }
            </tbody>

        </table>
        <table class="table table-sm table-striped table-bordered p-2 m-2">
            <thead>
            <tr>
                <th>服务器Key限制(/min)</th>
                <th>Key</th>
                <th>Key剩余请求</th>
            </tr>
            </thead>

            <tbody>
            @if (Model.Table.KeyAvailable.Count == 0)
            {
                <tr>
                    <td>@Model.ServerBaseLimit.KeyRequestLimit</td>
                    <td></td>
                    <td></td>

                </tr>
            }
            else
            {
                @foreach (var keyValuePair in Model.Table.KeyAvailable)
                {
                    <tr>
                        <td>@Model.ServerBaseLimit.KeyRequestLimit</td>
                        <td>@keyValuePair.Key</td>
                        <td>@keyValuePair.Value</td>
                    </tr>
                }
            }
            </tbody>

        </table>

    </div>
</div>
<table class="table table-sm table-striped table--bordered">
    <thead>
    <tr>
        <th>索引</th>
        <th>动态密钥</th>
    </tr>
    </thead>
    <tbody>
    @for (var i = 0; i < Model.Repository.Count; i++)
    {
        <tr>
            <td>@i</td>
            @* @if (Model.Repository.OpenPoolKeys[i].Cipher != null) *@
            @* { *@
            @*      *@
            @* } *@
            @if (Model.Repository.OpenPoolKeys[i].Cipher?.Length >= 7)
            {
                <td>@Model.Repository.OpenPoolKeys[i].Cipher?[..7]</td>
            }

        </tr>
    }
    </tbody>
</table>
<table class="table-bordered table table-sm table-striped">
    <thead>
    <tr>
        <th>项目</th>
        <th>日志信息</th>
    </tr>
    </thead>
    <tbody>
    @for (var i = Model.Table.UseInfo.Count - 1; i >= 0; i--)
    {
        <tr>
            <td>@(i + 1)</td>
            <td>@Model.Table.UseInfo[i]</td>
        </tr>
    }
    </tbody>
</table>